<?php 

namespace app\api\controller;
use think\facade\Validate;
use think\facade\Filesystem;
use think\Image;
use think\exception\ValidateException;


class Base extends Common{
	
	
	/**
	* @api {get} /Base/captcha 01、图片验证码地址
	* @apiGroup Base
	* @apiVersion 1.0.0
	* @apiDescription  图片验证码
	*/
	public function captcha(){
        $key = uniqid(rand(00000,99999));
        $rs = \think\captcha\facade\Captcha::create();
        $base64_image = "data:image/png;base64," . base64_encode($rs->getData());
        $captcha = session('captcha.key');
        cache('ADMIN_LOGIN_VERIFY_'.$key,$captcha);
        if(config('rds.api_captcha_log')){
            \think\facade\Log::info('仅测试的验证码');
            \think\facade\Log::info($captcha);
        }
        $data['data'] = [
            'key'   => $key,
            'img'   => $base64_image,
        ];
        $data['status'] = 200;
		return json($data);
	}

}

